package cc.bluemc.modules.adminUser.entity;

import cc.bluemc.modules.adminUser.service.PermissionService;
import cc.bluemc.platform.annotation.fieldFormart.FieldFormart;
import cc.bluemc.platform.utils.BeanUtil;
import com.alibaba.fastjson.annotation.JSONField;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;

@Table(name="t_permission")
public class Permission implements Serializable{
    private Integer id;

    private String name;

    private String code;

    private String description;

    private Integer pid;
    
    @FieldFormart(clazz=PermissionService.class,method="get",paramsType={Integer.class})
    @JSONField(serialize=false)
    @Transient
    private Permission permi;

    private PermissionType type;
    
    private String url;
    @Transient
    private Boolean checked;
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Id
    public Integer getId() {
        return id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public Integer getPid() {
        return pid;
    }
	public PermissionType getType() {
		return type;
	}
	public void setType(PermissionType type) {
		this.type = type;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public Permission getPermi() {
		if(null==permi){
			Object o= BeanUtil.fieldFormat(this,"permi",this.getPid());
			permi=(Permission) o;
		}
		return permi;
	}

	public void setPermi(Permission permi) {
		this.permi = permi;
		this.pid=permi.getId();
	}
	
	public Boolean getChecked() {
		return checked;
	}

	public void setChecked(Boolean checked) {
		this.checked = checked;
	}
	
}
